<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>ECharts</title>
    <!-- 引入 echarts.js -->
    <script src="../js/echarts.min.js"></script>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    <!-- 引入 layui.css -->
    <link rel="stylesheet" href="//unpkg.com/layui@2.6.8/dist/css/layui.css">

    <!-- 引入 layui.js -->
    <script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>
</head>

<body>
<!-- 为ECharts准备一个具备大小（宽高）的Dom -->
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
    var result='';
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));
    $(function () {

        $.ajax
        ({
            url: "/echarts/list",
            dataType: "json",
            type: "get",
            success: function (res) {
                // 指定图表的配置项和数据
                var option = {
                    color: ["#003366", "#006699", "#4cabce"],
                    result:[],
                    title: {
                        backgroundColor: 'rgba(128, 128, 128, 0.5)',
                        text: 'ECharts 入门示例',
                        subtext: 'ECharts副标题',
                        textAlign: 'auto',
                        link: 'www.sougou.com',
                        triggerEvent: true,
                        itemGap: 8,
                        top: -5,
                        borderColor: 'green',
                        aria: {
                            enable: true,
                            decal: {
                                show: true
                            }
                        },
                        borderRadius: [5, 5, 0, 0],
                        padding: [20, 10, 600, 400],
                        target: 'self',
                        textStyle: {
                            fontStyle: 'oblique',
                            color: 'red',
                            fontWeight: 'bold',
                            fontFamily: 'serif',
                            fontSize: 18,
                            lineHeight: 20,
                            textBorderType: 'dashed',
                            textBorderDashOffset: 50,
                            textShadowColor: 'green',
                            textShadowBlur: 50
                        },
                        subtextStyle: {
                            lineHeight: 9,
                            fontSize: 10,
                            fontWeight: 'bold',
                            fontFamily: 'serif',
                            fontStyle: 'oblique',
                            color: 'red',
                        },

                    },


                    tooltip: {},
                    legend: {
                        data: ['销量', '单价', '大小'],
                        type: 'scroll',
                        orient: 'vertical',
                        //  backgroundColor: 'rgba(128, 128, 128, 0.5)',
                        left: 50,
                        icon: 'circle',
                        itemGap: 5,
                        itemWidth: 30,
                        itemStyle: {
                            color: 'inherit',
                            decal: 'inherit',
                            opacity: 0.3
                        },
                        formatter: function (name) {
                            return name;
                        },
                        inactiveColor: 'red',
                        selected: {
                            // 选中'系列1'
                            '销量': true,
                            // 不选中'系列2'
                            '单价': false,
                            '大小': false
                        },
                        textStyle: {
                            color: 'red',
                            fontStyle: 'italic',
                            fontWeight: 'lighter',
                            fontFamily: 'Arial',
                            lineHeight: 200,
                            rich: {

                            }
                        }
                    },
                    xAxis: {
                        data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
                    },
                    yAxis: {result},
                    series: [
                        {
                            name: '销量',
                            type: 'line',
                            data: res
                        }, {
                            name: '单价',
                            type: 'bar',
                            data: res
                        }, {
                            name: '大小',
                            type: 'bar',
                            data: res
                        }
                    ],


                };
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);
            },
            error: function () {
                alert('failed!');
            },
        });
    })







</script>
<style type="text/css">
    .button {
        width: 100px;
        height: 29px;
        font-size: 16px;
        color: white;
        background-color: black;
        padding: 0;
        vertical-align: top;
        border: 0;
    }

    .textbox {
        height: 25px;
        padding: 0;
        vertical-align: top;
    }

    span {
        font-size: 16px;
        height: 29px;
        line-height: 29px;
    }
</style>
</body>

</html>
